package cn.conchit.apccontroldemo.graph.canvas;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * @author hetao
 * @version 1.0
 * @description: TODO
 * @date 2023/2/14 16:16
 */


@Data
@NoArgsConstructor
@AllArgsConstructor
public class Edge<E> {
    private int tailIndex;
    private int headIndex;
    private Edge<E> headLink;
    private Edge<E> tailLink;

    private E info;



    public Edge(int tailIndex, int headIndex, E info) {
        this.tailIndex = tailIndex;
        this.headIndex = headIndex;
        this.info = info;
        headLink = null;
        tailLink = null;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Edge<?> edge = (Edge<?>) o;
        return tailIndex == edge.tailIndex && headIndex == edge.headIndex;
    }

    @Override
    public int hashCode() {
        return Objects.hash(tailIndex, headIndex, headLink, tailLink, info);
    }
}
